<template>
   <div class="Yiji_blog_container">
        <h2>FROM OUR BLOGS</h2>
        <div class="Yiji_blog">
            <div v-for="item in product.slice(4, 7)" :key="item.theme_id">
                <div class="blog_img_box">
                    <img :src=item.pic_url alt="">
                </div>
                <p>{{item.theme_title}}</p>
                <p>{{item.theme_content}}</p>
                <div class="read_more" @click="toReadMore(item.theme_id)">阅读更多</div>
            </div>
        </div>
   </div>
</template>
<script>
export default {
  name:'HomeShowCloth',
  data(){
      return{
          product:[]
      }
  },
  methods: {
      toReadMore(theme_id){
           this.$router.push({
        path: "/communitymenu",
        query: { id: theme_id },
      });
      }
  },
  created() {
    this.$axios.get('/api/users/getCommunity').then((res)=>{
        this.product = res.data.results;
    })
  },
}

</script>
<style scoped>
.Yiji_blog_container {
    width: 100%;
}

.Yiji_blog_container h2 {
    text-align: center;
    margin-bottom: 20px;
}

.Yiji_blog {
    width: 1170px;
    height: 500px;
    margin: 0 auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    
}

.Yiji_blog>div {
    width: 380px;
    height: 100%;
    background-color: #F6F7F8;
    position: relative;
}

.blog_img_box {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.blog_img_box img {
    width: 100%;
    height:100%;
    object-fit: cover;
    transition: all 0.6s;
}
.blog_img_box img:hover{
    transform: scale(1.1);
}

.Yiji_blog div p:nth-child(2) {
    font-size: 20px;
    font-weight: 600;
    margin: 20px;
    overflow: hidden;
    text-overflow:ellipsis;
    line-height: 25px;
    height: 50px;
}

.Yiji_blog div p:nth-child(3) {
    text-indent:35px;
    font-size: 16px;
    margin: 20px;
    overflow: hidden;
    text-overflow:ellipsis;
    display:-webkit-box;  
    -webkit-box-orient:vertical;  
    -webkit-line-clamp:4; 
}

.read_more {
    font-size: 16px;
    background-color: #434343;
    width: 120px;
    height: 40px;
    margin: 40px auto;
    color: white;
    border-radius:5px;
    text-align: center;
    line-height: 40px;
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform:translateX(-50%);
}

.read_more:hover{
    background-color: #4e6ef2;
    cursor: pointer;
}

</style>